
import json
import pandas as pd

csv_data = {
    'id':[],
    'query':[],
    'A':[],
    'B':[],
    'C':[],
    'D':[],
    'E':[],
    'question_type':[]
}
with open('/home/llm_user/index/medical/llm-retrieval-qa/data/CMB-Exam/CMB-test/CMB-test-choice-question-merge.json','r',encoding='utf-8') as f:
    data = json.load(f)
    # 
    for item in data:
        if item['exam_class'] == '中医学与中药学':
            options = item['option']
            # assert len(options) == 5, f"{item}"
            csv_data['id'].append(item['id'])
            csv_data['query'].append(item['question'])
            for _option in options:
                if _option not in csv_data:
                    continue
                csv_data[_option].append(_option + '. ' + options[_option])
            csv_data['question_type'].append(item['question_type'])
df = pd.DataFrame(csv_data)

df.to_csv('/home/llm_user/index/medical/llm-retrieval-qa/data/test/medical-2.csv',index=False)